/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.cashmate.servlet;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author DELL
 */
public class Checks extends HttpServlet {
   
         @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        HttpSession session = request.getSession();

        if(session.getAttribute("type") != null){
            response.sendRedirect("HomePageAdmin");
        }

        out.println("<html>");
        out.println("<head>");
        out.println("<title>Log In Administrators</title>");
        out.println("<link rel = 'stylesheet' href = 'style.css' />");
        out.println("<link rel='shortcut icon' type='image/vnd.microsoft.icon' href='images/favicon.ico' />");
        out.println("</head>");
        out.println("<body>");

        RequestDispatcher rd = request.getRequestDispatcher("WEB-INF/fragment/header.jsp");
        rd.include(request, response);
        rd = request.getRequestDispatcher("WEB-INF/fragment/adminlogin.jsp");
        rd.include(request, response);
        if(request.getParameter("status") != null){
            if("noval".equals(request.getParameter("status"))){
                out.println("<p class = 'error'> The username you have entered does not exist. Please try again.</p>");
            }else if("uop".equals(request.getParameter("status"))){
                out.println("<p class = 'error'> The password you have entered is incorrect. Please try again.</p>");
            }
        }
        rd = request.getRequestDispatcher("WEB-INF/fragment/footer.html");
        rd.include(request, response);

        out.println("</body>");
        out.println("</html>");

    }
}
